<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>爱淘爱生活</title>
        <meta name="viewport" content="initial-scale=1,maximum-scale=1">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
        <link rel="stylesheet" type="text/css" href="/source/site.css?<?=\Config\System::$site['version']?>">
        <link rel="shortcut icon" href="/source/icon.png">
    </head>
    <body>
        <!--page集合的容器-->
        <div class="page-group">
            <!--单个page,第一个默认展示-->
            <div class="page">
                <header class="bar bar-nav">
                    <h1 class="title"><a href="/my/invite" class="external">我的邀请</a></h1>
                </header>

                <?php
                include TPL_PATH . 'toolBar.html';
                ?>

                <!--页面内容区域-->
                <div class="content tab-main-list">
                    <?php
                    include TPL_PATH . 'index/tab_invite.html';
                    ?>
                    <?php if ($data_list): ?>
                    <?php foreach($data_list as $d): ?>
                    <div class="card">
                        <div class="card-content">
                            <div class="list-block media-list">
                                <div class="item-content">
                                    <div class="item-media">
                                        <?php if ($d['headimgurl']): ?>
                                        <img src="<?=$d['headimgurl']?>" width="60">
                                        <?php else: ?>
                                        <img src="<?=\Config\System::$site['thumb']?>" width="60">
                                        <?php endif; ?>
                                    </div>
                                    <div class="item-inner">
                                        <div class="item-title">
                                            <p><?php if ($d['nickname']): ?>
                                                <?=$d['nickname']?>
                                                <?php else: ?>
                                                uid<?=$d['id']?>
                                                <?php endif; ?>
                                            </p>
                                            <p class="font-gray"><?=date('Y-m-d H:i:s', $d['invittime'])?></p>
                                            <?php if ($d['monpacket'] > 0): ?>
                                            <p>
                                                月领红包<span class="red"><?=$d['monpacket']?>元</span>
                                            </p>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endforeach; ?>

                    <div class="item-content" style="text-align: center; margin: 2rem 0 1rem 0;">
                        <?php
                        $last_page = $page - 1;
                        $next_page = $page + 1;
                        ?>
                        <?php if($last_page > 0): ?>
                        <a href="/my/invite?page=<?=$last_page?>" class="button button-fill external" style="display: inline-block; margin: 0 1rem">上一页</a>
                        <?php endif; ?>
                        <?php if($next_page <= $total_page): ?>
                        <a href="/my/invite?page=<?=$next_page?>" class="button button-fill external" style="display: inline-block; margin: 0 1rem">下一页</a>
                        <?php endif; ?>
                    </div>
                    <?php else: ?>
                    <div class="item-content">
                        <p>你还没有邀请好友，快去邀请吧！<a href="/index/invite" class="external">立即邀请</a></p>
                    </div>
                    <?php endif; ?>
                </div>
                <?php include TPL_PATH . 'panel.html'; ?>
            </div>
        </div>

        <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
        <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
        <script type="text/javascript">
            $(function () {
                $('.buttons-tab a').click(function () {
                    var type = $(this).attr('href');
                    var url = '';
                    if (type == '#user') {
                        url = '/my/invite';
                    }
                    if (type == '#packet') {
                        url = '/my/invitepacket';
                    }
                    window.location.href = url;
                });
            });
        </script>
    </body>
</html>